import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { MaterialTypeVO, MaterialTypeForm, MaterialTypeQuery } from '@/api/base/material/materialType/types';

/**
 * 查询物料类型列表
 * @param query
 * @returns {*}
 */
export const listMaterialType = (query?: MaterialTypeQuery): AxiosPromise<MaterialTypeVO[]> => {
  return request({
    url: '/base/material/materialType/list',
    method: 'get',
    params: query
  });
};

/**
 * 获取物料类型列表
 * @param query
 * @returns {*}
 */
export const queryList = (query?: MaterialTypeForm): AxiosPromise<MaterialTypeForm[]> => {
  return request({
    url: '/base/material/materialType/queryList',
    method: 'get',
    params: query
  });
};

/**
 * 查询物料类型详细
 * @param id
 */
export const getMaterialType = (id: string | number): AxiosPromise<MaterialTypeVO> => {
  return request({
    url: '/base/material/materialType/' + id,
    method: 'get'
  });
};

/**
 * 新增物料类型
 * @param data
 */
export const addMaterialType = (data: MaterialTypeForm) => {
  return request({
    url: '/base/material/materialType',
    method: 'post',
    data: data
  });
};

/**
 * 修改物料类型
 * @param data
 */
export const updateMaterialType = (data: MaterialTypeForm) => {
  return request({
    url: '/base/material/materialType',
    method: 'put',
    data: data
  });
};

/**
 * 删除物料类型
 * @param id
 */
export const delMaterialType = (id: string | number | Array<string | number>) => {
  return request({
    url: '/base/material/materialType/' + id,
    method: 'delete'
  });
};

export default {
  queryList
};
